
// cheerio_demo.js

const fs = require('fs');
const cheerio = require('cheerio');


const test1 = () => {
    let $ = cheerio.load('<h2 class="title">Hello world</h2>')
    console.log($.html())
    $('h2.title').text('Hello there!');
    $('h2').addClass('welcome');
    console.log($.html())
};

const test2 = () => {
    const html = fs.readFileSync('./html_fragment.html', 'utf8')
    let $ = cheerio.load(html);
    // console.log($.html())
    let len = $('li').length;
    console.log(len)
};

const test3 = () => {
    const html = fs.readFileSync('./51jobdata.html', 'utf8')
    let $ = cheerio.load(html);
    // 51 - 1 , 每页50个职位
    console.log( $('div.dw_table').find('div.el').length )
};

(function main() {
    // test1();
    // test2();
    test3();
})()

